{% extends 'themes/default/public/layout.html' %}

{% block style %}
<link rel="stylesheet" href="{{url_for('static', filename='layui/css/layui.css')}}">
<style>
    .contact-box {
        padding: 20px;
        background-color: #fff;
        border: 1px solid #e7eaec;
        overflow: hidden;
    }
    .contact-box a img {
        width: 100%;
    }
    .users-title {
        margin: 0 0 5px;
    }
    .users-address strong {
        margin-bottom: 5px;
        display: block;
    }
</style>
{% endblock %}

{% block body %}
<div class="mdui-container-fluid">
    <div class="nexmoe-item">
        <div class="mdui-row">
<!--            <button class="layui-btn" layadmin-event="create">创建文件夹</button>-->
            <button class="layui-btn" id="uploadssmall">上传小于4M文件</button>
            <button class="layui-btn" id="uploadsbig">上大于4M传文件</button>
           <ul class="mdui-list">
                <li class="mdui-list-item th">
                    <div class="mdui-col-xs-12 mdui-col-sm-6">文件 </div>
                    <div class="mdui-col-sm-3 mdui-text-right">修改时间 </div>
                    <div class="mdui-col-sm-2 mdui-text-right">大小 </div>
                    <div class="mdui-col-sm-1 mdui-text-right">状态 </div>
                </li>
               {% for v in data %}
                    <li class="mdui-list-item mdui-ripple">
                        {% if v.file=="image/jpeg" %}
                            <a href="/users/get_files_downloadUrl/{{ v.uid }}/{{ v.disk_id }}/{{ v.files_id }}" class="lightboxurl" data-lightbox="lightbox">
                                <div class="mdui-col-xs-12 mdui-col-sm-6 mdui-text-truncate">
                                    <i class="mdui-icon material-icons">image</i>
                                    <span>{{ v.name }}</span>
                                    <span class="down_users_file down_file_icon" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                        <i class="mdui-icon material-icons">cloud_download</i>
                                    </span>
                                </div>
                                <div class="mdui-col-sm-3 mdui-text-right">{{ v.update_time }}</div>
                                <div class="mdui-col-sm-2 mdui-text-right">{{ v.size }}</div>
                                <div class="mdui-col-sm-1 mdui-text-right">{{ v.status }}</div>
                            </a>
                        {% elif v.file=="image/png" %}
                            <a href="/users/get_files_downloadUrl/{{ v.uid }}/{{ v.disk_id }}/{{ v.files_id }}" class="lightboxurl" data-lightbox="lightbox">
                                <div class="mdui-col-xs-12 mdui-col-sm-6 mdui-text-truncate">
                                    <i class="mdui-icon material-icons">image</i>
                                    <span>{{ v.name }}</span>
                                    <span class="down_users_file down_file_icon" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                        <i class="mdui-icon material-icons">cloud_download</i>
                                    </span>
                                </div>
                                <div class="mdui-col-sm-3 mdui-text-right">{{ v.create_time }}</div>
                                <div class="mdui-col-sm-2 mdui-text-right">{{ v.size }}</div>
                                <div class="mdui-col-sm-1 mdui-text-right">{{ v.status }}</div>
                            </a>
                        {% elif v.file=="audio/mpeg" %}
                            <a href="javascript:void(0);" class="{% if webconfig.is_music == '1' %}addMusicList{% else %}users_video_open{% endif %}" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                <div class="mdui-col-xs-12 mdui-col-sm-6 mdui-text-truncate">
                                    <i class="mdui-icon material-icons">music_note</i>
                                    <span>{{ v.name|safe }}</span>
                                    <span class="down_users_file down_file_icon" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                        <i class="mdui-icon material-icons">cloud_download</i>
                                    </span>
                                </div>
                                <div class="mdui-col-sm-3 mdui-text-right">{{ v.update_time }}</div>
                                <div class="mdui-col-sm-2 mdui-text-right">{{ v.size }}</div>
                                <div class="mdui-col-sm-1 mdui-text-right">{{ v.status }}</div>
                            </a>
                        {% elif v.file=="audio/x-wav" %}
                            <a href="javascript:void(0);" class="{% if webconfig.is_music == '1' %}addMusicList{% else %}users_video_open{% endif %}" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                <div class="mdui-col-xs-12 mdui-col-sm-6 mdui-text-truncate">
                                    <i class="mdui-icon material-icons">music_note</i>
                                    <span>{{ v.name|safe }}</span>
                                    <span class="down_users_file down_file_icon" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                        <i class="mdui-icon material-icons">cloud_download</i>
                                    </span>
                                </div>
                                <div class="mdui-col-sm-3 mdui-text-right">{{ v.update_time }}</div>
                                <div class="mdui-col-sm-2 mdui-text-right">{{ v.size }}</div>
                                <div class="mdui-col-sm-1 mdui-text-right">{{ v.status }}</div>
                            </a>
                        {% elif v.file=="video/mp4" %}
                            <a href="javascript:void(0);" class="users_video_open" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                <div class="mdui-col-xs-12 mdui-col-sm-6 mdui-text-truncate">
                                    <i class="mdui-icon material-icons">videocam</i>
                                    <span>{{ v.name }}</span>
                                    <span class="down_users_file down_file_icon" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                        <i class="mdui-icon material-icons">cloud_download</i>
                                    </span>
                                </div>
                                <div class="mdui-col-sm-3 mdui-text-right">{{ v.update_time }}</div>
                                <div class="mdui-col-sm-2 mdui-text-right">{{ v.size }}</div>
                                <div class="mdui-col-sm-1 mdui-text-right">{{ v.status }}</div>
                            </a>
                        {% elif v.file=="application/octet-stream" %}
                            {% if v.name|thereisStr(".flac") %}
                                <a href="javascript:void(0);" class="{% if webconfig.is_music == '1' %}addMusicList{% else %}users_video_open{% endif %}" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                    <div class="mdui-col-xs-12 mdui-col-sm-6 mdui-text-truncate">
                                        <i class="mdui-icon material-icons">music_note</i>
                                        <span>{{ v.name|safe }}</span>
                                        <span class="down_users_file down_file_icon" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                            <i class="mdui-icon material-icons">cloud_download</i>
                                        </span>
                                    </div>
                                    <div class="mdui-col-sm-3 mdui-text-right">{{ v.update_time }}</div>
                                    <div class="mdui-col-sm-2 mdui-text-right">{{ v.size }}</div>
                                    <div class="mdui-col-sm-1 mdui-text-right">{{ v.status }}</div>
                                </a>
                            {% else %}
                                <a href="javascript:void(0);" class="users_video_open" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                    <div class="mdui-col-xs-12 mdui-col-sm-6 mdui-text-truncate">
                                        <i class="mdui-icon material-icons">videocam</i>
                                        <span>{{ v.name }}</span>
                                        <span class="down_users_file down_file_icon" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                            <i class="mdui-icon material-icons">cloud_download</i>
                                        </span>
                                    </div>
                                    <div class="mdui-col-sm-3 mdui-text-right">{{ v.update_time }}</div>
                                    <div class="mdui-col-sm-2 mdui-text-right">{{ v.size }}</div>
                                    <div class="mdui-col-sm-1 mdui-text-right">{{ v.status }}</div>
                                </a>
                            {% endif %}
                        {% elif v.file=="application/msword" %}
                            <a href="javascript:void(0);" class="down_users_file" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                <div class="mdui-col-xs-12 mdui-col-sm-6 mdui-text-truncate">
                                    <i class="mdui-icon material-icons">description</i>
                                    <span>{{ v.name }}</span>
                                    <span class="down_users_file down_file_icon" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                        <i class="mdui-icon material-icons">cloud_download</i>
                                    </span>
                                </div>
                                <div class="mdui-col-sm-3 mdui-text-right">{{ v.update_time }}</div>
                                <div class="mdui-col-sm-2 mdui-text-right">{{ v.size }}</div>
                                <div class="mdui-col-sm-1 mdui-text-right">{{ v.status }}</div>
                            </a>
                        {% elif v.file=="application/vnd.ms-excel" %}
                            <a href="javascript:void(0);" class="down_users_file" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                <div class="mdui-col-xs-12 mdui-col-sm-6 mdui-text-truncate">
                                        <i class="mdui-icon material-icons">description</i>
                                    <span>{{ v.name }}</span>
                                    <span class="down_users_file down_file_icon" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                        <i class="mdui-icon material-icons">cloud_download</i>
                                    </span>
                                </div>
                                <div class="mdui-col-sm-3 mdui-text-right">{{ v.update_time }}</div>
                                <div class="mdui-col-sm-2 mdui-text-right">{{ v.size }}</div>
                                <div class="mdui-col-sm-1 mdui-text-right">{{ v.status }}</div>
                            </a>
                        {% elif v.file=="application/pdf" %}
                            <a href="javascript:void(0);" class="down_users_file" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                <div class="mdui-col-xs-12 mdui-col-sm-6 mdui-text-truncate">
                                        <i class="mdui-icon material-icons">description</i>
                                    <span>{{ v.name }}</span>
                                    <span class="down_users_file down_file_icon" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                        <i class="mdui-icon material-icons">cloud_download</i>
                                    </span>
                                </div>
                                <div class="mdui-col-sm-3 mdui-text-right">{{ v.update_time }}</div>
                                <div class="mdui-col-sm-2 mdui-text-right">{{ v.size }}</div>
                                <div class="mdui-col-sm-1 mdui-text-right">{{ v.status }}</div>
                            </a>
                        {% elif v.file=="application/zip" %}
                            <a href="javascript:void(0);" class="down_users_file" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                <div class="mdui-col-xs-12 mdui-col-sm-6 mdui-text-truncate">
                                    <i class="mdui-icon material-icons">view_day</i>
                                    <span>{{ v.name }}</span>
                                    <span class="down_users_file down_file_icon" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                        <i class="mdui-icon material-icons">cloud_download</i>
                                    </span>
                                </div>
                                <div class="mdui-col-sm-3 mdui-text-right">{{ v.update_time }}</div>
                                <div class="mdui-col-sm-2 mdui-text-right">{{ v.size }}</div>
                                <div class="mdui-col-sm-1 mdui-text-right">{{ v.status }}</div>
                            </a>
                        {% elif v.file=="folder" %}
                            <a href="{{ current_url }}/{{ v.name }}">
                                <div class="mdui-col-xs-12 mdui-col-sm-6 mdui-text-truncate">
                                    <i class="mdui-icon material-icons">folder_open</i>
                                    <span>{{ v.name }}</span>
                                </div>
                                <div class="mdui-col-sm-3 mdui-text-right">{{ v.update_time }}</div>
                            </a>
                        {% else %}
                            <a href="javascript:void(0);" class="down_users_file" data-uid="{{v.uid}}" data-disk="{{v.disk_id}}" data-filesid="{{v.files_id}}" data-name="{{ v.name|safe }}">
                                <div class="mdui-col-xs-12 mdui-col-sm-6 mdui-text-truncate">
                                    <i class="mdui-icon material-icons">view_day</i>
                                    <span>{{ v.name }}</span>
                                </div>
                                <div class="mdui-col-sm-3 mdui-text-right">{{ v.create_time }}</div>
                                <div class="mdui-col-sm-2 mdui-text-right">{{ v.size }}</div>
                                <div class="mdui-col-sm-1 mdui-text-right">{{ v.status }}</div>
                            </a>
                        {% endif %}
                    </li>
                {% endfor %}
           </ul>
        </div>
    </div>
</div>
{% endblock %}

{% block script %}
<script>
     // 新增一个创建文件夹事件
    //  clickMethod.create = function () {
    //      layer.prompt({title: '输入文件夹名称', formType: 0}, function(fileName, index){
    //          $.ajax({
    //               url: "/users/folder_create"
    //              ,type: "POST"
    //              ,dataType: "json"
    //              ,data: {id:"", path:"", fileName:fileName}
    //              ,success: function (data) {
    //                  if(data.code==0){
    //                      layer.close(index);
    //                      location.reload()
    //                  }else{
    //                      layer.msg(data.msg)
    //                  }
    //              }
    //          });
    //      });
    // };

    // 新增一个上传文件事件
    $("#uploadsbig").on("click", function () {
        layer.open({
            type: 2
            ,title: '上传大文件'
            ,shadeClose: false
            ,area: ["800px", "550px"]
            ,content: '/users/file_uploads_big/{{files_disk_id}}'
            ,end: function () {
                tablerender();  // 渲染表格
            }
        })
    });
    // 新增一个上传文件事件
    $("#uploadssmall").on("click", function () {
        layer.open({
            type: 2
            ,title: '上传小文件'
            ,shadeClose: false
            ,area: ["800px", "550px"]
            ,content: '/users/file_uploads_small/{{files_disk_id}}'
            ,end: function () {
                tablerender();  // 渲染表格
            }
        })
    });

    // 弹出下载
    $(".down_users_file").on("click", function () {
        event.stopPropagation();    //  阻止事件冒泡
        var uid = $(this).data("uid"),
            disk_id = $(this).data("disk"),
            files_id = $(this).data("filesid"),
            name = $(this).data("name");
        var url = "/users/down_users_file/" + uid + "/" + disk_id + "/" + files_id + "/?filename=" + name;
        layer.confirm('是否确认下载？', {
            btn: ['确认','取消']
        }, function(index){
            window.location.href = url;
            layer.close(index);
        });
    });

    $(".users_video_open").on("click", function () {
        var uid = $(this).data("uid"),
            disk_id = $(this).data("disk"),
            files_id = $(this).data("filesid");
        var url = "/users/users_pop_video/" + uid + "/" + disk_id + "/" + files_id;
        //适配手机端
        if($(window).width() < 500) {
            var d_width = "95%";
            var shadeClose = true;
            var closeBtn = 0;
        }else{
            var d_width = "50%";
            var shadeClose = false;
            var closeBtn = 1;
        }

        layer.open({
            type: 2,
            title: false,
            area: [d_width, '60%'],
            shade: 0.8,
            closeBtn: closeBtn,
            shadeClose: shadeClose,
            content: url
        });
    });
</script>
{% endblock %}